<?php
include_once '../../__global.php';

class aj_delFavourite extends ml_controller {

    private $rid;
    private $uid;

    function initParam() {

        $this->rid = $this->input('rid', 'p', 0);
        $this->uid = $this->__visitor['uid'];
    }

    function checkParam() {

        $this->check_referer();
        if ($this->check_permission(ML_PERMISSION_LOGOUT_ONLY)) {
            $this->api_output(ML_RCODE_NOLOGIN);
        }

        if ($this->check_permission(ML_PERMISSION_UNVERIFY_ONLY)) {
            $this->api_output(ML_RCODE_NOACTIVE);
        }

        if (!ml_tool_resid::is_resid($this->rid)) {
            $this->api_output(ML_RCODE_PARAM,'','wrong rid');
        }

        if (!ml_tool_isuid::is_mluid($this->uid)) {
            $this->api_output(ML_RCODE_PARAM,'','wrong uid');
        }
//        if (ml_tool_resid::resid2uid($this->rid) != $this->uid) {
//            $this->api_output(ML_RCODE_HACK);
//        }

    }

    function main() {


        $ilike = new ml_model_dbILike();
        $rs=$ilike->deleteLike($this->uid, $this->rid);
        //？？？？扣除宝贝的得分和表态数吗？问产品拉  不减
        if($rs)
        {
            ml_tool_actionlog::del_attitude($this->__visitor['uid'] , $this->rid);
            $this->api_output(ML_RCODE_SUCC);
        }
        else
        $this->api_output(ML_RCODE_FAIL,'','fail');
    }
}

new aj_delFavourite();